package com.bruan.d6_singleInstance;

public class B {
    //懒汉式单例
    //2。定义类对象
    private static B b;
    //1.把类的构造器私有
    private B(){

    }
    //3.定义类方法
    public static B getObj(){
        if (b == null){
            return new B();
        }
        return b;
    }
}
